package com.neu.flashmall.order.config;

import com.alipay.api.*;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliPayConfig {
    //APPID对应支付宝账号
    public static String APP_ID="2021000121600594";
    //应用私钥
    public static String MERCHANT_PRIVATE_KEY="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC+ulmjrvu3ZQZoJ+EiI+wW7mD+9WVUBiXQQ3DsbzTA2Pc72DAIT8N3lWd21FmsVzYd3U822/a4Ord8u49QFG2bevXDBTzNzP3QFFdBbGflBXn9DaB2cELnXD7oA9mWfYfuvKK4G2hFgBdQ7MN+spFVrCbqaMBjRXsvWCv+MYNCpWPewn735Lk4j1BiR/V4PDAaI1L/4WzBBNdso1HsRduR15XH6Yb0hS4+ySfCYwz91ePv/2PX2U1BpiZrPymv+kwAYGXz6FWGKpsFdckvcZ5odyCuaJaFdqTDIF5o35vBh1/Zk+FgB638zBphv4JH36tvj3Rgvly/Xwf8bMT5bbi7AgMBAAECggEASWVlAXxhGZ4i7QoLtRulyt1JLlQ4/jCvdIm/dv0EjAHygnEbatdnHSm9exkUuSGGjc+QoEfdld/ipHl5GRQDagXTdY0abQgp1F0/hsm04YlN/He1/F4PIQF6o8Z3gVYlbVXiOH8zjStRza6PPL5y90kcYLCW+JzQXtPLejKLlKVt6dsO7/ZJ80RhdcHsnMZtVqgV70JA5gqC2Gtu3w2d/TgbUBo7BgPtMLUxte/PgTBW5Juswac4wH54CSPKa6nVhALnZAsLUTpxaK8yEyn+7lwKjox7lQLDt1WOtLLM7m2Q4YWJmmclNaZIzt6sHCHUkXSeY+bGyXL2+9Ax3RcsoQKBgQD0qe+hrWu4u6rQc9nAGr0PV94cayghVzEX1sNRLMEhTuLqWEaFVsmRHroRdcd2oO0cl9dj/s1VbU+q18tHpESzgyS/HXmhhDOutj+65MZZ9M39clvp1eClZCOwVyEHhHbSHlWcw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hQ4RQHOgRDaDHUGKQiRMRcolp7PUEyZq/DBtrqWQZqfJZo8XGY9UA9zp7A4hRjYJUoZIdFx7Ps7NnB0OCEFjlAQIDAQAB";
    //这个是支付成功后要跳转到哪里的页面  success是我控制层里面的路径  改成自己的  也可以是一个页面.html
    public static String NOTIFY_URL="http://localhost:8081/oms_order/notify";
    //页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问  和上面一样
    public static String RETURN_URL="http://localhost:8081/pay/callback";
    //支付宝网关(沙盒环境)  不用改
    public static String GATEWAY_URL="https://openapi.alipaydev.com/gateway.do";

    @Bean
    public AlipayClient alipayClient() throws AlipayApiException {
        AlipayConfig alipayConfig = new AlipayConfig();
        //设置网关地址
        alipayConfig.setServerUrl(GATEWAY_URL);
        //设置应用ID
        alipayConfig.setAppId(APP_ID);
        //设置应用私钥
        alipayConfig.setPrivateKey(MERCHANT_PRIVATE_KEY);
        //设置字符集
//        alipayConfig.setCharset(AlipayConstants.CHARSET_UTF8);
        //设置请求格式，固定值json
//        alipayConfig.setFormat(AlipayConstants.FORMAT_JSON);
        //设置支付宝公钥
        alipayConfig.setAlipayPublicKey(ALIPAY_PUBLIC_KEY);
        //设置签名类型
        alipayConfig.setSignType(AlipayConstants.SIGN_TYPE_RSA2);
        //构造client
        AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);

        System.out.println("*****************支付宝SDK初始化完成***************");
        return alipayClient;
    }
}
